  <style type="text/css">
    @media print {
      .noprint { display: none; }
    }
    
    #backtocourse {
    background-image: url("/images/arrows/arrow_long_darkblue.png");
    color: white;
    cursor: pointer;
    height: 28px;
    margin-top: 10px;
    padding-left: 5px;
    padding-top: 8px;
    width: 205px;
}
  </style>


<div id=attendence_filter><strong>Filter by:</strong> Attendance Type:<select id=cmb_filter onChange="search_box.filter_courses()"></select></div>
<div id=type_note style=height:0px,width:0px; ></div>

<?php 
if(!isset($_SESSION)) session_start();

//if (! isset($_SESSION["ProspectusCode"])) {
 //   echo "<script type='text/javascript'>alert('{$_SESSION["ProspectusCode"]}')</script>";
//}

$StudyYear  = isset($_REQUEST["StudyYear"]) ? $_REQUEST["StudyYear"] : 2011; 
$search_subject = $_SESSION["search_subject"];
$search_category = $_SESSION["search_category"];
$search_key_words = $_SESSION["search_key_words"];
$search_mode = $_SESSION["search_mode"];

$data_file = "{$_SERVER["DOCUMENT_ROOT"]}/modules/search_box/data/SubjectAreaSearch_{$StudyYear}_{$search_category}_{$search_subject}_{$search_mode}_{$search_key_words}.json";

if (!file_exists($data_file)) {
    $params = "StudyYear={$StudyYear}&SubjectAreaCode={$search_subject}&Category={$search_category}&KeyWord={$search_key_words}&mode={$search_mode}";
    $feed = "http://{$_SERVER['SERVER_NAME']}/WebServices/PRC/service.asmx/SubjectAreaSearch?{$params}";
    $xml = simplexml_load_file($feed);
    file_put_contents($data_file, json_encode($xml));
}


$data  = file_get_contents($data_file);


$json = json_decode($data);

    
    
	echo "<div id=ProspectusList style=display:none>";
	if (isset($json->ProspectusList->Prospectus)) {
	
		
	$info = $json->ProspectusList->Prospectus;	
	
	
	
	$count = 0;
	if (isset($info->Code)) {
		$count = 1;
		$info = $json->ProspectusList;
	} else foreach ($info as $p) {$count++;}
	if ($count == 1) echo "<div>$count course found</div>";
	else echo "<div>$count courses found</div>";
	
	echo <<<STOP
	<div id=course_title_bar>
	<div class=course_title_bar_course>Course</div>
	<div class=course_title_bar_level>Level</div>
	<div class=course_title_bar_start>Course Start</div>
        <div class=course_title_bar_type>Type</div>
	</div>
	
	
STOP;
	
    foreach ($info as $prospectus) {
    	
    	$level  = (! is_object($prospectus->Level)) ? $prospectus->Level : "X";
    	
    	if ($level=="") $level="X";
    	
    	
     	try {
    	echo "<div id=prospectus_item class=\"prospectus_item prospectus_level_{$level}\">";
    	echo "<a href=\"Javascript:search_box.goProspectus('{$prospectus->Code}','{$prospectus->StartDate}')\">";
    	echo "<div class=prospectus_description>{$prospectus->Description}</div>";
    	echo "<div class=prospectus_level>&nbsp;$level</div>";
    	echo "<div class=prospectus_start>{$prospectus->StartDate}</div>";
		echo "<div class=type_note mode=\"{$prospectus->Mode}\" ";
		echo ">";
 
        switch ($prospectus->Mode)  {
        	case "Part Time Programme" : echo "&#9687;"; break;
        	case "Full Time Programme" : echo "&#9679;"; break;
                
        }
        echo "<div style=\"position:absolute;background-color:white;display:none;font-size:10pt\">{$prospectus->Mode}</div>";
    	
    	echo "</div>";
    	echo "</a>";
    	echo "</div>";
    	} catch (Exception $e) { echo $e->getMessage();}
    	
    }
    
   
	}
    echo "</div>";
    

?>

<script type="text/javascript">


$(document).ready(function(){ 
	//search_box.load_filter_options();
	$(".type_note").mouseleave(function () {search_box.hide_note()});
	
    $("#info_bar").hide();
    $("#content_text").css("width", "650px");
	$(".type_note").each(function () {
	if ($(this).attr("mode") == "Full Time Programme") $(this).css("font-size", "150%");
	});
	
    $("#ProspectusList").css("display","block");
	$(".prospectus_item").children().each(function(){
		var h = 0;
		$(this).children().each(function(){
                    if ($(this).height() > h) h = $(this).height();
                    
		});
                $(this).children().each(function(){
                     $(this).height(h)
		});
	});
	search_box.load_subject_areas();

	
	set_height();
});

</script>

<?php 

/*
}  else {
    
    $StudyYear=$_SESSION["study_year"];
    $ProspectusCode=$_SESSION["ProspectusCode"];
    echo<<<STOP
    <div id=ProspectusList></div>   
    
    
    
    <script type='text/javascript'>search_box.goProspectus('{$ProspectusCode}','{$StudyYear}');</script>
STOP;
}
 * 
 */
?>


